<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>开启流程</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="../../assets/js/jquery-2.0.3.min.js"></script>
    <script src="../../assets/js/bootstrap.min.js"></script>
    <script src="../../assets/js/hammer.min.js"></script>
    <script src="../../assets/js/bootstrap.table/bootstrap-table.min.js" type="text/javascript"></script>
    <script src="../../assets/js/bootstrap.table/bootstrap-table-zh-CN.min.js" type="text/javascript"></script>
    <script src="../../assets/js/date-time/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
    <script src="../../assets/js/date-time/bootstrap-datetimepicker.zh-CN.js" type="text/javascript"></script>
    <script src="../../assets/js/jquery.ztree.all.min.js"></script>
    <script src="../../assets/js/dialog.js"></script>
    <script src="../../assets/js/common.js" type="text/javascript"></script>
    <script src="../../assets/js/jquery.cookie.js" type="text/javascript"></script>
    <script src="../../assets/js/myUrl.js" type="text/javascript"></script>
    <script src="../../assets/js/datepicker/js/foundation-datepicker.js"></script>
    <script src="../../assets/js/datepicker/js/locales/foundation-datepicker.zh-CN.js"></script>
    <script src="../../html/activiti/editor-app/libs/es5-shim-15.3.4.5/tests/lib/json2.js"></script>
    <script src="activiti.js"></script>

    <link href="../../assets/css/bootstrap.min.css" rel="stylesheet" />
    <link href="../../assets/css/bootstrap.table/bootstrap-table.min.css"/>
    <link href="../../assets/js/datepicker/css/foundation-datepicker.css" rel="stylesheet" type="text/css" />
    <link href="../../assets/css/dialog.css" rel="stylesheet" />
    <link href="../../assets/css/zTreeStyle.css" rel="stylesheet" />
    <link href="../../assets/css/common.css" rel="stylesheet" />

</head>
<style type="text/css">
    a,a:hover,a:visited,a:link{
        cursor: pointer;
        text-decoration: none;
    }
</style>
<script type="text/javascript">


    $(function () {
        //调用函数，初始化表格
        initTable();
    })
    
    function getForm(developmentId, defId) {
        var options = {"developmentId":developmentId};
        var result = myAjax(options, local_url.activiti_model_devolpement_form,  "GET");
        console.info(result);

        var elem1 = document.getElementById('addProcessForm');
        $("#nodeDataForm").html("");
        var htmls = coverHtml(result.data);
        $("#nodeDataForm").html(htmls);
        createDateController(result.data);
        dialog({
            title: "新增",
            content: elem1,
            width: '40em',
            okValue: "确定",
            ok: function () {
                var dataValue = $('#nodeDataForm').parseForm();
                dataValue["processDefId"] = defId;
                var console = myAjax(dataValue, local_url.activiti_start_process, "PUT");
                if(console.code=="200"){
                    promptDail("开启成功！");
                    return true;
                }else if(console.code!="5000") {
                    promptDail("开启失败！");
                }
                return false;
            },
            cancelValue: '取消',
            cancel: function () {}
        }).showModal();
    }

    function editModel() {
        var valueInfo = $('#mytab').bootstrapTable('getSelections');
        if(valueInfo!=null&&valueInfo!=""&&valueInfo.length>0) {
            jump(valueInfo[0].id);
        }else {
            promptDail('请选择一条数据!');
        }
    }



    
    function initTable() {
        commonInitTable(local_url.activiti_process_list, "mytab", null)
    }

    function clearInput(){
        $("#name").val("");
        $("#revision").val("");
        $("#key").val("");
        $("#description").val("");
    }

    function saveCheckDataInfo() {
        var b1 = checkValue("name");
        var b2 = checkValue("revision");
        var b3 = checkValue("key");
        var b4 = checkValue("description");
        if(b1&&b2&&b3&&b4){
            return true;
        }

        return false;
    }
</script>
<body style="padding:5px;">
<div class="panel panel-default" >
    <div class="panel-heading">
        查询条件
    </div>
    <div class="panel-body form-group" style="margin-bottom:0px;">
        <form id="searchForm">
        <label class="col-sm-2 control-label" style="width: 10%;text-align: right; margin-top:5px">流程名称：</label>
        <div class="col-sm-2">
            <input type="text" class="form-control" name="names" id="names"/>
        </div>
        <div class="col-sm-1">
            <button class="btn btn-primary" id="search_btn" onclick="initTable();return false;">查询</button>
        </div>
        </form>
    </div>
</div>
<table id="mytab" data-toggle="table" class="table table-hover table-bordered" data-single-select="true"
       data-toolbar-align="right" data-toolbar="#toolbar" data-pagination="true"  data-page-size="10"
       data-page-list="[10,20,30]" data-pagination-h-align="right" data-pagination-detail-h-align="left"
       data-pagination-loop="false" data-click-to-select="true" >
    <colgroup>
        <col style="width: 5%">
        <col style="width: 10%">
        <col style="width: 20%">
        <col style="width: 15%">
        <col style="width: 20%">
        <col style="width: 10%">
        <col style="width: 10%">
    </colgroup>
    <thead>
        <tr >
            <th data-align="center" data-valign="middle" data-checkbox="true" ></th>
            <th data-align="center" data-valign="middle" data-field="id" data-visible="false">模型id</th>
            <th data-align="center" data-valign="middle" data-field="name">流程名称</th>
            <th data-align="center" data-valign="middle" data-field="key">流程定义ID</th>

            <th data-align="center" data-valign="middle" data-field="version">版本</th>
            <th data-align="center" data-valign="middle" data-field="suspensionState">是否挂起</th>
            <th data-align="center" data-valign="middle" data-field="description">描述</th>
            <th data-align="center" data-valign="middle" data-field="deploymentId" data-visible="false">部署id</th>
            <th data-align="center" data-valign="middle" data-formatter="initEdit">开启</th>
        </tr>
    </thead>
</table>


<div id="addProcessForm" style="display: none;">
    <div style="width: 100%;margin-top: 10px;height: 260px;overflow-x: hidden;overflow-y: auto;">
        <form class="form-horizontal" id="nodeDataForm" role="form">
        </form>
    </div>
</div>
</body>
<script type="text/javascript">
    function initEdit(val, row, index) {
        var html = "";
        html += "<a href=\'javascript:void(0)\' onclick=getForm(\'"+row.deploymentId+"\',\'"+row.id+"\')>【开启】</a>";
        return html;
    }

</script>
</html>